#include <time.h>

#include <cassert>
#include <climits>
#include <iostream>

#include "graph/graph.h"
#include "list/circular_list.h"
#include "list/list.h"
#include "math/euclidean.h"
#include "path_planning/astar.h"
#include "path_planning/dijkstra.h"
#include "recursion/factorial.h"
#include "recursion/reverse_list.h"
#include "tree/tree.h"

int main()
{
    testListForRecursion();

    {
        // 示例图：4个节点（0:A, 1:B, 2:C, 3:D）
        std::vector<std::vector<std::pair<int, int>>> graph = {
            {{1, 10}, {2, 3}},  // A到B(10), 到C(3)
            {{3, 5}},           // B到D(4)
            {{1, 4}, {3, 8}},   // C到B(4), C到D(8)
            {}                  // D没有出边
        };

        int distance = INT_MAX;
        bool ret = dijkstra(graph, 3, distance);
        assert(11 == distance);
    }

    {
        // 设置起点和终点
        Point2D start(0, 0);
        Point2D goal(3, 3);

        std::vector<Point2D> path;

        bool ret = aStarSearch<Point2D>(
            start, goal, [](const Point2D& pt) -> bool
            { return pt.x == 1.0 && pt.y == 1.0 || pt.x == 2.0 && pt.y == 2.0; }, path);

        assert(ret);

        if (path.empty())
        {
            std::cout << "未找到路径!" << std::endl;
        }
        else
        {
            std::cout << "找到路径:" << std::endl;
        }
    }

    return 0;
}